import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isCollapse:true,
    
    items: [
      {
        icon: "el-icon-s-home",
        index: "dashboard",
        title: "系统首页",
      },
      {
        icon: "el-icon-menu",
        index: "table",
        title: "基础表格",
      },
      {
       icon: "el-icon-document-copy",
        index: "tabs",
        title: "tab选项卡",
      },
      {
        icon: "el-icon-document",
        index: "3",
        title: "表单相关",
        subs: [
          {
            index: "form",
            title: "基本表单",
          },
          {
            index: "3-2",
            title: "三级菜单",
            subs: [
              {
                index: "editor",
                title: "富文本编辑器",
              },
              {
                index: "markdown",
                title: "markdown编辑器",
              },
            ],
          },
          {
            index: "upload",
            title: "文件上传",
          },
        ],
      },
      {
        icon: "el-icon-watermelon",
        index: "icon",
        title: "自定义图标",
      },
      {
        icon: "el-icon-pie-chart",
        index: "charts",
        title: "schart图表",
      },
      {
        icon: "el-icon-rank",
        index: "6",
        title: "拖拽组件",
        subs: [
          {
            index: "drag",
            title: "拖拽列表",
          },
          {
            index: "dialog",
            title: "拖拽弹框",
          },
        ],
      },
      {
        icon: "el-icon-loading",
        index: "i18n",
        title: "国际化功能",
      },
      {
        icon: "el-icon-close",
        index: "7",
        title: "商品处理",
        subs: [
          {
            index: "permission",
            title: "商品管理",
          },
          {
            index: "404",
            title: "品类管理",
          },
        ],
      },
      {
        icon: "el-icon-star-on",
        index: "donate",
        title: "用户首页",
      },
    ],
    navlist:[],
  },
  mutations: {
        // 导航开关
    changeIsCollapse(state){
      state.isCollapse = !state.isCollapse

    },
    // 面包屑添加
    // ...es6新语法
       
    add(state,id){
      console.log(id)
      state.navlist.push(id)
      state.navlist=[...new Set(state.navlist)]   // 添加数组中  
      if(state.navlist.length>8){    //判断不能超过8个面包屑标签
        state.navlist.shift()
      }
      console.log(state.navlist)
    },
  // 关闭标签
    del(state,id){
      console.log(id)
      state.navlist.splice(id,1)
    }
  },
  actions: {
  },
  modules: {
  }
})
